/* ==================================================================   
 * Created [2009-4-27 下午11:32:55] by Jon.King 
 * ==================================================================  
 * TSS 
 * ================================================================== 
 * mailTo:jinpujun@hotmail.com
 * Copyright (c) Jon.King, 2009-2012 
 * ================================================================== 
 */

package com.jinhe.tss.um.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jinhe.tss.core.Global;
import com.jinhe.tss.core.web.dispaly.XmlPrintWriter;
import com.jinhe.tss.core.web.dispaly.xmlhttp.XmlHttpEncoder;
import com.jinhe.tss.um.service.IPasswordRuleService;

/** 
 * <p> GetPasswordStrength.java </p>
 * 获取密码强度
 */
public class GetPasswordStrengthServlet extends HttpServlet {

	private static final long serialVersionUID = -192831928301L;
 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		String loginName = request.getParameter("loginName");
		String password  = request.getParameter("password");
		
		IPasswordRuleService service = (IPasswordRuleService) Global.getContext().getBean("PasswordRuleService");
		String level = service.getStrengthLevel(null, password, loginName);
		
		response.setContentType("text/html;charset=GBK");
		XmlHttpEncoder encoder = new XmlHttpEncoder();
		encoder.put("SecurityLevel", level);
		encoder.print(new XmlPrintWriter(response.getWriter()));
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		doPost(request, response);
	}
}
